package com.demo.shardingjdbc.utils;

import java.io.Serializable;

/**
 * 统一返回结果集
 */
public class AjaxResult implements Serializable {

    /**
     * 响应状态码，200-成功 其余均为失败
     */
    private Integer code = 200;

    /**
     * 说明
     */
    private String msg = "成功";

    /**
     * 数据
     */
    private Object data;


    public static AjaxResult success(Object data) {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setMsg("ok");
        result.setData(data);
        return result;
    }

    public static AjaxResult success() {
        AjaxResult result = new AjaxResult();
        result.setCode(200);
        result.setMsg("ok");
        return result;
    }


    public static AjaxResult error(Integer code,String msg) {
        AjaxResult result = new AjaxResult();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}

